package de.lusiardi.webdav.headers;

import java.util.logging.Logger;

/**
 * http://www.webdav.org/specs/rfc4918.html#HEADER_If
 *
 * @author shing19m
 */
public class IfHeader implements Header {

    private static final Logger logger = Logger.getLogger(IfHeader.class.getCanonicalName());

    public static final String KEY = "If";

    private String value;

    public String getKey() {
        return KEY;
    }

    public void setValue(String val) {
        value = val;
        if (!checkValue()) {
            logger.warning(String.format("'%s' is an invalid value for If header.", value));
        }
    }

    public String getValue() {
        return value;
    }

    /**
     * http://www.webdav.org/specs/rfc4918.html#HEADER_If
     * <pre>If = "If" ":" ( 1*No-tag-list | 1*Tagged-list )      *
     * No-tag-list = List
     * Tagged-list = Resource-Tag 1*List
     *
     * List = "(" 1*Condition ")"
     * Condition = ["Not"] (State-token | "[" entity-tag "]")
     * ; entity-tag: see Section 3.11 of [RFC2616]
     * ; No LWS allowed between "[", entity-tag and "]"
     *
     * State-token = Coded-URL
     *
     * Resource-Tag = "<" Simple-ref ">"
     * ; Simple-ref: see Section 8.3
     * ; No LWS allowed in Resource-Tag</pre>
     *
     * @return
     */
    public boolean checkValue() {
        return true;
    }
}
